package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Exercicio;


@Controller
public class exercicioController {
	
	@Inject
	private Result result;
	
	@Inject
     private GenericDAO<Exercicio> dao;
	

	public void adde(){
		
	}
	public List<Exercicio> liste(){
		return dao.find();
		
	}
public void save(Exercicio exercicio){
		
		dao.save(exercicio);
		
		result.redirectTo(this).liste();
	}
	
	public Exercicio edit(Integer id){
		return dao.find(id);
	}
	
	public void delete(int id){
		Exercicio exercicio = new Exercicio();
		exercicio.setId(id);
		dao.delete(exercicio);
		result.redirectTo(this).liste();
	}
	
}
	
	
	

